package cn.iocoder.yudao.module.fengdong.smartelderly.dal.mysql.address;

import java.util.*;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.fengdong.smartelderly.dal.dataobject.address.AddressDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.fengdong.smartelderly.controller.admin.address.vo.*;
import org.apache.ibatis.annotations.Param;

/**
 * 我的地址 Mapper
 *
 * @author 沣东养老院管理员
 */
@Mapper
public interface AddressMapper extends BaseMapperX<AddressDO> {

    default PageResult<AddressDO> selectPage(AddressPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<AddressDO>()
                .likeIfPresent(AddressDO::getName, reqVO.getName())
                .eqIfPresent(AddressDO::getPhone, reqVO.getPhone())
                .eqIfPresent(AddressDO::getAreaId, reqVO.getAreaId())
                .eqIfPresent(AddressDO::getArea, reqVO.getArea())
                .eqIfPresent(AddressDO::getContent, reqVO.getContent())
                .betweenIfPresent(AddressDO::getCreateTime, reqVO.getCreateTime())
                .eqIfPresent(AddressDO::getStatus, reqVO.getStatus())
                .orderByDesc(AddressDO::getId));
    }

    default List<AddressDO> selectList(AddressExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<AddressDO>()
                .likeIfPresent(AddressDO::getName, reqVO.getName())
                .eqIfPresent(AddressDO::getPhone, reqVO.getPhone())
                .eqIfPresent(AddressDO::getAreaId, reqVO.getAreaId())
                .eqIfPresent(AddressDO::getArea, reqVO.getArea())
                .eqIfPresent(AddressDO::getContent, reqVO.getContent())
                .betweenIfPresent(AddressDO::getCreateTime, reqVO.getCreateTime())
                .eqIfPresent(AddressDO::getStatus, reqVO.getStatus())
                .orderByDesc(AddressDO::getId));
    }

    void updateStates(@Param("userId") Long loginUserId);
}
